const path = require("path");
const Htmlwebpackplugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const { HotModuleReplacementPlugin } = require("webpack");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const webpack = require('webpack')

module.exports = {
    mode: 'none',
    entry: path.join(__dirname, 'src/main.js'), // 入口文件
    output: {
        filename: "bundle.js",
        path: path.resolve(__dirname, "dist")
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    // "style-loader",
                    MiniCssExtractPlugin.loader,
                    "css-loader",
                    {
                        loader: "postcss-loader",
                        options: {
                            ident: "postcss",
                            plugins: () => [require("postcss-preset-env")()]
                        }
                    }
                ]
            },
            {
                test: /\.less$/,
                use: [
                    // "style-loader",
                    MiniCssExtractPlugin.loader,
                    "css-loader",
                    {
                        loader: "postcss-loader",
                        options: {
                            ident: "postcss",
                            plugins: () => [require("postcss-preset-env")()]
                        }
                    },
                    "less-loader"
                ]
            },
        ]
    },
    devServer: {
        contentBase: 'public', //静态资源访问
    },
    plugins: [
        new CleanWebpackPlugin(),
        new HotModuleReplacementPlugin()
    ]
}